# Maintainer: Oscar Fuentes <ofv@wanadoo.es>

_realname=ctags
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=6.1.0
pkgrel=1
pkgdesc="Generates an index file of language objects found in source files (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
provides=("${MINGW_PACKAGE_PREFIX}-universal-${_realname}"
          "${MINGW_PACKAGE_PREFIX}-universal-${_realname}-git")
conflicts=("${MINGW_PACKAGE_PREFIX}-universal-${_realname}"
           "${MINGW_PACKAGE_PREFIX}-universal-${_realname}-git")
replaces=("${MINGW_PACKAGE_PREFIX}-universal-${_realname}"
          "${MINGW_PACKAGE_PREFIX}-universal-${_realname}-git")
url='https://ctags.io/'
msys2_repository_url="https://github.com/universal-ctags/ctags"
msys2_references=(
  'archlinux: ctags'
)
license=('spdx:GPL-2.0-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-python-docutils")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-jansson"
         "${MINGW_PACKAGE_PREFIX}-libiconv"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-libyaml"
         "${MINGW_PACKAGE_PREFIX}-pcre2")
source=("https://github.com/universal-ctags/ctags/releases/download/v${pkgver}/universal-ctags-${pkgver}.tar.gz")
sha256sums=('fa3bafbd0dab0373c0c1788c79451bad4eed2095ad292a8dd46cc1ae6997b2c5')

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../"universal-${_realname}-${pkgver}"/configure \
    --prefix="${MINGW_PREFIX}" \
    --build="${MINGW_CHOST}" \
    --disable-etags \
    --disable-external-sort

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  make install DESTDIR="${pkgdir}"

  install -Dm644 "${srcdir}/universal-${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
